package com.sinodata.bsm.cicp.collector.net.trap;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class TCPTranslate {
    private static Logger logger = Logger.getLogger(TCPTranslate.class.getName());
    public static Map<String, String[]> map = new HashMap<String, String[]>();

    public static void readxml() {
        try {
            SAXReader saxReader = new SAXReader();
            Document doc = saxReader.read(new File("conf/net/event.xml"));
            List<Element> eventEl = doc.getRootElement().elements("event");
            for (Element event : eventEl) {
                parserEventElement(event);
            }
        } catch (DocumentException e) {
            logger.error("" + e, e);
        }
    }

    private static void parserEventElement(Element event) {
        String oid = event.attribute(0).getText();
        String level = event.attribute(1).getText();
        String eventString = event.getText();
        String[] eventStrings = { eventString, level };
        map.put(oid, eventStrings);
    }

    public static void main(String[] args) {
        //        TCPTranslate tc = new TCPTranslate();
        //        tc.readxml();
    }
}
